from django.db import models
from django.contrib.auth import get_user_model
OAUser = get_user_model()
class AbsentType(models.Model):
    name = models.CharField(max_length=50)
    creat_time = models.DateTimeField(auto_now_add=True)

class AbsentStatusChoices(models.IntegerChoices):
    # 1：审批中，2：审核通过，3：拒绝
    AUDIING = 1
    PASS = 2
    REJECT = 3
# 请假
class Absent(models.Model):
    #标题
    title = models.CharField(max_length=50)
    # 请假详细内容
    content = models.TextField()
    # 请假的类型
    type = models.ForeignKey(AbsentType, on_delete=models.CASCADE, related_name='absents', related_query_name='absents')
    # 发起人
    requester = models.ForeignKey(OAUser, on_delete=models.CASCADE,related_name='my_absents',related_query_name='my_absents')
    # 审批人（可以为空）
    responder = models.ForeignKey(OAUser, null= True, on_delete=models.CASCADE,related_name='sub_absents',related_query_name='sub_absents')
    # 状态
    status = models.IntegerField(choices=AbsentStatusChoices,default=AbsentStatusChoices.AUDIING)
    # 请假的开始时间
    start_time = models.DateTimeField()
    # 请假的结束时间
    end_time = models.DateTimeField()
    creat_time = models.DateTimeField(auto_now_add=True)
    # 审批回复内容
    reply_content = models.TextField(null=True)